#! /usr/bin/perl
use strict;
use warnings;

###### 
# NGSbox - bioinformatics analysis tools for next generation sequencing data
#
# Copyright 2007-2011 Stephan Ossowski, Korbinian Schneeberger
# 
# NGSbox is free software: you can redistribute it and/or modify it under the 
# terms of the GNU General Public License as published by the Free Software 
# Foundation, either version 3 of the License, or any later version.
#
# NGSbox is distributed in the hope that it will be useful, but WITHOUT ANY 
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# Please find the GNU General Public License at <http://www.gnu.org/licenses/>.
#
#  -------------------------------------------------------------------------
#
#  Module: Parser::FASTA::chop_sequence_2_reads.pl
#  Purpose:
#  In:
#  Out:
#


my $usage = "$0 length file\n";

my $len = shift or die $usage;
my $file = shift or die $usage;

open FILE, $file or die "Cannot open input file";
my $seq = "";
my $id = "";

while ( <FILE> ) {
	chomp;

	if (substr($_, 0, 1) eq ">") {
		if ($seq ne "") {
			cho($seq);
		}
		$seq = "";
	}
	else {
		$seq .= $_;
	}
}

cho($seq);

sub cho {
	my ($seq) = @_;

	for (my $i = 0; $i < length($seq) - $len; $i++) {
		my $shoreid = 1000000000 + $i;
		print "$shoreid\t" , substr($seq, $i, $len), "\t0\t";
		for(my $j = 0; $j < $len; $j++) {
			print "I";
		}
		print "\n";
	}
}


